﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using GalaSoft.MvvmLight.Messaging;
using HP.Cachalote.WPF.ViewModel;
using HP.Cachalote.WPF.Shared;

namespace HP.Cachalote.WPF.UserControls
{
    /// <summary>
    /// Interaction logic for FinishedTodoItemTreeViewUserControl.xaml
    /// </summary>
    public partial class FinishedTodoItemTreeViewUserControl : UserControlBase
    {
        private bool _showTreeView = false;

        public FinishedTodoItemTreeViewUserControl()
        {
            InitializeComponent();
        }

        protected override void RegisterMessages()
        {
            base.RegisterMessages();
            RegisterDeleteAllDoneItemsConfirmMessage();
        }

        /// <summary>
        /// Register message from FinishedTodoItemTreeViewModel to show a confirm window.
        /// </summary>
        private void RegisterDeleteAllDoneItemsConfirmMessage()
        {
            Messenger.Default.Register<DialogMessage>(this, FinishedTodoItemTreeViewModel.DeleteAllDoneItemsConfirmMessageToken, dialog =>
            {
                //var confirmResult = MessageBox.Show(dialog.Content, dialog.Caption, dialog.Button, dialog.Icon);

                var dialogWindow = new DialogWindow(dialog.Content);
                dialogWindow.ShowDialog();

                var confirmResult = dialogWindow.Result;
                dialog.ProcessCallback(confirmResult);
            });
        }

        private void treeViewlVisibilityControlButton_Click(object sender, RoutedEventArgs e)
        {
            var storyboard = _showTreeView ? FindResource("StoryboardHideTreeView") as Storyboard : FindResource("StoryboardRestoreTreeView") as Storyboard;
            _showTreeView = !_showTreeView;
            storyboard.Begin();
        }
    }
}
